classdef INCAR
  %INCAR Summary of this class goes here
  %   Detailed explanation goes here
  
  properties
    System;
    PREC;
    ENCUT;
    ISTART;
    ICHARG;
    
    LREAL;
    
    ISMEAR;
    IBRION;
    ISIF;
    NSW;
    

  end

  methods

  end
  
  methods(Static)
    function write_ion_relaxation()
      fid = fopen('INCAR', 'wt');
      fprintf(fid, 'system = Force \n');
      fprintf(fid, 'PREC = accurate \n'); % PREC = high no longer recommended
      fprintf(fid, 'ISTART = 0 \n');
      fprintf(fid, 'ICHARG = 2 \n \n');
      
      fprintf(fid, 'NEDOS = 1000 \n');
      fprintf(fid, 'LREAL = Auto \n\n');
      
      fprintf(fid, 'ISMEAR = -5 \n'); % avoid ISMEAR > 0 for semiconductors and insulators
      fprintf(fid, 'IBRION = 2 \n'); % CG for ion relaxation
      fprintf(fid, 'ISIF = 2 \n'); % CG for ion relaxation
      fclose(fid);
    end
    
    function write_lattice_relaxation()
      fid = fopen('INCAR', 'wt');
      fprintf(fid, 'system = Force \n');
      fprintf(fid, 'PREC = accurate \n');
      fprintf(fid, 'ISTART = 0 \n');
      fprintf(fid, 'ICHARG = 2 \n \n');
      
      fprintf(fid, 'NEDOS = 1000 \n');
      fprintf(fid, 'LREAL = Auto \n\n');
      
      fprintf(fid, 'ISMEAR = -5 \n'); % avoid ISMEAR > 0 for semiconductors and insulators
      fprintf(fid, 'IBRION = 2 \n'); % CG for ion relaxation
      fprintf(fid, 'ISIF = 7 \n'); % change cell volume
      fclose(fid);
    end
    
    
    function write_sc()
      fid = fopen('INCAR', 'wt');
      fprintf(fid, 'system = sc \n');
      fprintf(fid, 'PREC = accurate \n');
      fprintf(fid, 'ISTART = 1 \n');
      fprintf(fid, 'ICHARG = 1 \n');
      fprintf(fid, 'NSW = 0 \n \n');
      
      fprintf(fid, 'NEDOS = 1000 \n');
      fprintf(fid, 'LREAL = Auto \n\n');
      
      fprintf(fid, 'ISMEAR = -5 \n'); % avoid ISMEAR > 0 for semiconductors and insulators
      fprintf(fid, 'IBRION = -1 \n'); % ions fixed
      fclose(fid);
    end
    
    function write_bandstructure()
      fid = fopen('INCAR', 'wt');
      fprintf(fid, 'system = Bandstructure \n');
      fprintf(fid, 'PREC = accurate \n');
      fprintf(fid, 'ISTART = 0 \n');
      fprintf(fid, 'ICHARG = 11 \n \n');
      
      fprintf(fid, 'NEDOS = 1000 \n');
      fprintf(fid, 'LREAL = Auto \n\n');
      
      fprintf(fid, 'ISMEAR = -5 \n'); % avoid ISMEAR > 0 for semiconductors and insulators
      fprintf(fid, 'IBRION = -1 \n'); % ions fixed
      fclose(fid);
    end
    
    
    function write_DOS()
      fid = fopen('INCAR', 'wt');
      fprintf(fid, 'system = DOS \n');
      fprintf(fid, 'PREC = accurate \n');
      fprintf(fid, 'ISTART = 0 \n');
      fprintf(fid, 'ICHARG = 11 \n \n');
      
      fprintf(fid, 'NEDOS = 3000 \n');
      fprintf(fid, 'LREAL = Auto \n\n');
      
      fprintf(fid, 'ISMEAR = -5 \n'); % avoid ISMEAR > 0 for semiconductors and insulators
      fprintf(fid, 'IBRION = -1 \n'); % ions fixed
      fprintf(fid, 'LORBIT = 10 \n'); % density of states
      fclose(fid);
    end


  end
end

